import React, { Component } from "react";
import { connect } from "react-redux";
// import {getPost} from '../../request'
import { fetchList } from "../../action/request";

import Item from "./item";
class ArticList extends Component {
  componentDidMount() {
    // getPost()
    //     .then(res=>{
    //         console.log('res',res.data)
    //     })
    console.log("item", this.props);
    this.props.fetchList();
  }
  render() {
    console.log("item2", this.props);
    return (
      <>
        {this.props.isLoading ? (
          <div>isLoding</div>
        ) : (
          <ul>
            {this.props.list.map((item) => {
              return <Item key={item.id} {...item}></Item>;
            })}
          </ul>
        )}
      </>
    );
  }
}
const mapState = (state) => {
  return { list: state.artic.list, isLoading: state.artic.isLoading };
};
export default connect(mapState, { fetchList })(ArticList);
